function encodeContentForLCA(e){_$arComponents={};_$compLength=0;var t=[];var r=0,n,i,s,a,f,o,l,u=0,_=0;while((r=e.indexOf("<?",r))>=0){u=0;n=r+2;i=false;s=false;while(n<e.length-1){n++;a=e.substr(n,1);if(!s){if(a=="/"&&n+1<e.length){f=e.indexOf("?>",n);if(f==-1){r=e.length;break}f+=2;o=0;if(e.substr(n+1,1)=="*"&&(o=e.indexOf("*/",n+2))>=0)o+=2;else if(e.substr(n+1,1)=="/"&&(o=e.indexOf("\n",n+2))>=0)o+=1;if(o>0){if(o>f&&e.substr(n+1,1)!="*"){t.push([r,f,e.substr(r,f-r)]);r=f;break}else n=o-1}continue}if(a=="?"&&n+1<e.length&&e.substr(n+1,1)==">"){n=n+2;t.push([r,n,e.substr(r,n-r)]);r=n+1;break}}if(s&&a=="\\"){i=true;continue}if(a=='"'||a=="'"){if(s){if(!i&&l==a)s=false}else{s=true;l=a}}i=false}if(n>=e.length)break;r=n}if(t.length>0){var p="";var d=0,v=[],b,O,C,T,h;var c="<?$APPLICATION->INCLUDECOMPONENT";var g=c.length;for(n=0;n<t.length;n++){C=t[n];h=false;if(C[2].substr(0,g).toUpperCase()==c){var w=str_pad_left(++_$compLength,4,"0");_$arComponents[w]=C[2];p+=e.substr(d,C[0]-d)+"#COMPONENT"+String(w)+"#"}else p+=e.substr(d,C[0]-d)+C[2];d=C[1]}e=p+e.substr(d)}return e}function decodeContentFromLCA(e){var t=function(e,t){var r=_$arComponents[t];if(!r)return"";return r};e=e.replace(/#COMPONENT(\d{4})#/gi,t);return e}function str_pad_left(e,t,r){e=String(e);if(r.length>0){var n="";var i=0;t=parseInt(t);for(var s=0,a=t-e.length;s<a;s++)n+=r;e=n+e}return e}function preview_template(e,t,r){if(window.GLOBAL_pMainObj){var n=GLOBAL_pMainObj["CONTENT"];if(n)n.SaveContent()}var i=BX("bxed_CONTENT").value;if(i.indexOf("#WORK_AREA#")==-1){alert(messErrorWA);return}BX.showWait();BX.ajax.post("/bitrix/admin/template_create_preview.php?ID="+e,{CONTENT:decodeContentFromLCA(i),STYLES:BX("__STYLES").value,TEMPLATE_STYLES:BX("__TEMPLATE_STYLES").value,sessid:t},function(){BX.closeWait();setTimeout(function(){if(window.__status)window.open("/?bitrix_preview_site_template="+r+"&bx_template_preview_mode=Y");else if(window.strWarning)alert(window.strWarning)},10)})}
//# sourceMappingURL=template_edit.map.js